@echo off
echo "==>TAO_ROOT=%TAO_ROOT%"

:: 创建和联合实时事件通道   AO_EC_Gateway_IIOP`
set PROJECT_PATH="%TAO_ROOT%/orbsvcs/DevGuideExamples/EventServices/RTEC_Federated"
cd %PROJECT_PATH%


@echo off
setlocal

:: 定义要删除的文件列表
set "files=ns.ior ec1.ior ec2.ior"

:: 遍历文件列表并删除存在的文件
for %%f in (%files%) do (
    if exist "%%f" (
        echo Deleting %%f...
        del "%%f"
        if not errorlevel 1 (
            echo Deleted %%f successfully.
        ) else (
            echo Error deleting %%f.
        )
    ) else (
        echo %%f does not exist. Skipping.
    )
)

:: 本地事件通道 + CORBA GW 实现发布订阅 24.3.8.1 使用 CORBA 消息作为底层通信机制。

::1) Start tao_ft_naming
echo "==>Start Naming_Service"
start "tao_cosnaming" cmd /k "%TAO_ROOT%/orbsvcs/Naming_Service/tao_cosnaming -ORBdebuglevel 0  -o %PROJECT_PATH%/ns.ior"
timeout /t 3


::2) Start test object EchoEventSupplier   -ecname ec1本地事件通道; -gateway ec2 远程事件通道
echo "==>Start EchoEventSupplier create local channel ec1"
start "EchoEventSupplier_ec1" cmd /k "EchoEventSupplier -ORBInitRef NameService=file://%PROJECT_PATH%/ns.ior  -ORBSvcConf supplier.conf -ecname ec1 -gateway ec2 -iorfile %PROJECT_PATH%/ec1.ior"
timeout /t 3


::3) Start test object EchoEventSupplier
echo "==>Start EchoEventSupplier create local channel ec2"
start "EchoEventSupplier_ec2" cmd /k "EchoEventSupplier -ORBInitRef NameService=file://%PROJECT_PATH%/ns.ior  -ORBSvcConf supplier.conf -ecname ec2 -gateway ec1 -iorfile %PROJECT_PATH%/ec2.ior"
timeout /t 3


::4) Start test object EchoEventConsumer  从命名服务上获取指定通道的使用, -ecname 指定本地事件通道
echo "==>Start EchoEventConsumer look for ec1"
start "EchoEventConsumer1_look_remote_ec1" cmd /k "EchoEventConsumer -ORBInitRef NameService=file://%PROJECT_PATH%/ns.ior -ecname ec1"
timeout /t 3

::5) Start test object EchoEventConsumer
echo "==>Start EchoEventConsumer look for ec2"
start "EchoEventConsumer_look_remote_ec2" cmd /k "EchoEventConsumer -ORBInitRef NameService=file://%PROJECT_PATH%/ns.ior -ecname ec2"
pause >nul
@echo off
